package book.crypto;

import java.math.BigInteger;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.SecretKey;

public class MacTest {

	public static void main(String[] args) throws NoSuchAlgorithmException, InvalidKeyException {
		
		KeyGenerator gen = KeyGenerator.getInstance("HmacMD5");
		SecretKey key = gen.generateKey();
		Mac mac = Mac.getInstance(key.getAlgorithm());
		mac.init(key);
		
		byte[] input = "MAC".getBytes();
		System.out.println(new BigInteger(mac.doFinal(input)));
	}
}
